package com.lishe.lishe.lishe.module.myorder.presenter;

import com.lishe.base.mvp.view.BaseMvpView;
import com.lishe.lishe.lishe.common.Globals;
import com.lishe.lishe.lishe.module.myorder.bean.OrderListResponse;
import com.lishe.lishe.net.BaseHttpLoader;
import com.lishe.lishe.net.BaseProtocal;
import com.lishe.lishe.net.NetAPI;
import com.lishe.lishe.net.ResultListener;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * 标    题：
 * 功能描述：
 * 作    者：zouxx
 * 创建时间：2018/8/21
 */

public class OrderListContract {

    public interface OrderListView extends BaseMvpView {

        void getOrderList(OrderListResponse bean);

        void cancelOrder(BaseProtocal baseProtocal);

        void confirmOrder(BaseProtocal baseProtocal);

        void onRequestFailure(int requestType, int errorCode, String msg);

        void onLoading(String text);
    }

    public static class OrderListModule {

        public void getOrderList(String token, String status, String page, String pageSize, ResultListener listener) {
            BaseHttpLoader loader = new BaseHttpLoader(OrderListResponse.class, Globals.LISHE_URL) {
                @Override
                public Observable<ResponseBody> structureObservable(NetAPI netAPI) {
                    return netAPI.getOrderList(token, status, page, pageSize);
                }
            };
            loader.executor(listener);
        }

        public void cancelOrder(String token, String paymentId, ResultListener listener) {
            BaseHttpLoader loader = new BaseHttpLoader(BaseProtocal.class, Globals.LISHE_URL) {
                @Override
                public Observable<ResponseBody> structureObservable(NetAPI netAPI) {
                    return netAPI.cancleOrder(token, paymentId);
                }
            };
            loader.executor(listener);
        }

        public void confirmOrder(String token, String paymentId, ResultListener listener) {
            BaseHttpLoader loader = new BaseHttpLoader(BaseProtocal.class, Globals.LISHE_URL) {
                @Override
                public Observable<ResponseBody> structureObservable(NetAPI netAPI) {
                    return netAPI.confirmOrder(token, paymentId);
                }
            };
            loader.executor(listener);
        }
    }

}
